package com.contain.listiterator;

import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;

/**
 * ListIterator的用法
 * 
 * @author Administrator
 * 
 */
public class Test {

	public static void main(String[] args) {
		List<Double> l = Arrays.asList(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
				9.0, 10.0);
		ListIterator<Double> it = l.listIterator();
		while (it.hasNext()) {
			System.out.println(it.next() + "," + it.nextIndex() + ","
					+ it.previousIndex());
		}
		System.out.println("================");
		while (it.hasPrevious()) {
			System.out.println(it.previous());
		}
		System.out.println("================");
		// 从某个职位开始遍历
		it = l.listIterator(3);
		while (it.hasNext()) {
			System.out.println(it.next());
		}
	}

}
